#include<bits/stdc++.h>
using namespace std;
struct node{
    int d,v,a,st,ed;
}car[3005];
int p[3005];
int dis[3005];
struct node1{
    int be,st,c;
}d[3005];
bool cmp(node1 &a,node1 &b){
    return a.c>b.c;
}
int tot1=0;
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%d",&T);
    while(T--){
        memset(p,0,sizeof(p));
            memset(car,0,sizeof(car));
            memset(dis,0,sizeof(dis));
            memset(d,0,sizeof(d));
        int n,m,L,V;
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&car[i].d,&car[i].v,&car[i].a);
            if(car[i].a!=0){
                if(car[i].v>V&&car[i].a>0) car[i].st=car[i].d,car[i].ed=L+1;
                else if(car[i].a>0){
                    int www=(V*V-car[i].v*car[i].v)/(2*car[i].a);
                    car[i].st=www+car[i].d;
                    car[i].ed=L+1;
                }
                else{
                    if(car[i].v<V) car[i].st=-1,car[i].ed=-1;
                    else{
                            if(car[i].a!=0){
                        int www=(car[i].v*car[i].v-V*V)/(2*car[i].a);
                        car[i].st=car[i].d;
                        car[i].ed=-1*www+car[i].d;
                            }
                    }
                }
            }
            else{
                if(car[i].v>V) car[i].st=car[i].d,car[i].ed=L+1;
                else car[i].st=-1,car[i].ed=-1;
            }
        }
        for(int i=1;i<=m;i++){
            scanf("%d",&p[i]);
        }
        int ans=0;
        for(int i=1;i<=n;i++){
                bool f3=0,f=1,f1=1;
            for(int j=1;j<=m;j++){
                    if(p[j]>=car[i].st&&p[i]<=car[i].ed){
                        f3=1;
                    }
                if(p[j]>=car[i].st&&p[j]<=car[i].ed&&f==1){
                    f=0;
                    f3=1;
                    dis[j]++;
                }
                if(p[j]>=car[i].ed&&f1==1&&f==0){
                    f1=0;
                    f3=1;
                    dis[j]--;
                }
            }
        if(f3==1){
            ans++;
        }
        }
        cout<<ans<<" ";
        d[++tot1].be=1;
        d[tot1].c=dis[1];
        for(int i=2;i<=m;i++){
            dis[i]+=dis[i-1];
            if(dis[i]==dis[i-1]){
                continue;
            }
            else{
                d[tot1].st=i-1;
                tot1++;
                d[tot1].be=i;
                d[tot1].c=dis[i];
            }
        }
        if(d[tot1].st!=3000){
            d[tot1].st=3000;
        }
        sort(d+1,d+tot1+1,cmp);
        int cnt1=0;
        int now1=0;
        while(cnt1<ans){
            now1++;
            cnt1+=d[now1].c;
        }
        cout<<m-now1;
    }
}
